package com.eling.elcms.community.model;

import com.eling.elcms.core.model.BaseModel;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import javax.persistence.*;

/**
 * 社区
 * 
 * @author KEN
 * 
 */
@Entity
@Table(name = "cm_community")
@Indexed
public class Community extends BaseModel {
    private static final long serialVersionUID = 3975517313435056368L;

    @Id
    @GeneratedValue(generator = "commGenerator")
    @GenericGenerator(name = "commGenerator", strategy = "com.eling.elcms.core.dao.hibernate.generator.AssignedIdentityGenerator")
    private Long pkCommunity;

    @Column(length = 60, unique = true, nullable = false)
    @Field
    private String name;
    
    @Column(length = 30, unique = true)
    @Field
    private String code;

    /** 邮编 */
    @Column(length = 30, nullable = false)
    @Field
    private String zipCode;
    
    /** 地址 */
    @Column(length = 255, nullable = false)
    @Field
    private String address;
    
    /** 描述、备注 */
    @Column(length = 1024)
    @Field
    private String description;

    /** 联系人1姓名 */
    @Column(length = 30)
    @Field
    private String contact1Name;

    /** 联系人1电话 */
    @Column(length = 30)
    @Field
    private String contact1Phone;

    /** 联系人1Email */
    @Column(length = 30)
    @Field
    private String contact1Email;
    
    /** 联系人1地址 */
    @Column(length = 255)
    @Field
    private String contact1Address;
    
    /** 联系人1邮编 */
    @Column(length = 30)
    @Field
    private String contact1ZipCode;

    /** 联系人2姓名 */
    @Column(length = 30)
    @Field
    private String contact2Name;

    /** 联系人2电话 */
    @Column(length = 30)
    @Field
    private String contact2Phone;

    /** 联系人2Email */
    @Column(length = 30)
    @Field
    private String contact2Email;
    
    /** 联系人2地址 */
    @Column(length = 255)
    @Field
    private String contact2Address;
    
    /** 联系人2邮编 */
    @Column(length = 30)
    @Field
    private String contact2ZipCode;

    /** 所属机构 */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pkOrganization", nullable = false, updatable = false)
    @IndexedEmbedded(depth = 1)
    private Organization organization;

    /** 会员数上限 */
    @Column(nullable = false)
    private Integer membersLimit;
    
    /** 权限IP，可以设置多IP，用分号分割，比如 12.23.34.45;23.34.45.56 */
    @Column
    @Field
    private String permissionIP;    

    @Version
    private int version;

	public Long getPkCommunity() {
		return pkCommunity;
	}

	public void setPkCommunity(Long pkCommunity) {
		this.pkCommunity = pkCommunity;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getContact1Name() {
		return contact1Name;
	}

	public void setContact1Name(String contact1Name) {
		this.contact1Name = contact1Name;
	}

	public String getContact1Phone() {
		return contact1Phone;
	}

	public void setContact1Phone(String contact1Phone) {
		this.contact1Phone = contact1Phone;
	}

	public String getContact1Email() {
		return contact1Email;
	}

	public void setContact1Email(String contact1Email) {
		this.contact1Email = contact1Email;
	}


	public String getContact1ZipCode() {
		return contact1ZipCode;
	}

	public void setContact1ZipCode(String contact1ZipCode) {
		this.contact1ZipCode = contact1ZipCode;
	}

	public String getContact2Name() {
		return contact2Name;
	}

	public void setContact2Name(String contact2Name) {
		this.contact2Name = contact2Name;
	}

	public String getContact2Phone() {
		return contact2Phone;
	}

	public void setContact2Phone(String contact2Phone) {
		this.contact2Phone = contact2Phone;
	}

	public String getContact2Email() {
		return contact2Email;
	}

	public void setContact2Email(String contact2Email) {
		this.contact2Email = contact2Email;
	}

	public String getContact2ZipCode() {
		return contact2ZipCode;
	}

	public void setContact2ZipCode(String contact2ZipCode) {
		this.contact2ZipCode = contact2ZipCode;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public Integer getMembersLimit() {
		return membersLimit;
	}

	public void setMembersLimit(Integer membersLimit) {
		this.membersLimit = membersLimit;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public String getContact1Address() {
		return contact1Address;
	}

	public void setContact1Address(String contact1Address) {
		this.contact1Address = contact1Address;
	}

	public String getContact2Address() {
		return contact2Address;
	}

	public void setContact2Address(String contact2Address) {
		this.contact2Address = contact2Address;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getPermissionIP() {
		return permissionIP;
	}

	public void setPermissionIP(String permissionIP) {
		this.permissionIP = permissionIP;
	}
	
	

}
